package com.cl.blog.web.manager;

import com.cl.blog.common.Result;
import com.cl.blog.service.impl.FileReadingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;

/**
 * @Author 付
 * @Date 2024-04-10 10:11
 * @Version 1.0
 * @description 敏感词控制层
 * @since 1.0
 */
@RequestMapping("/admin")
@RestController
public class AdminTouchyController {
	@Autowired
	private FileReadingService fileReadingService;

	@GetMapping("/touchy")
	public Result someMethod() {
		Map<String, String[]> keyValuePairs = fileReadingService.readKeyValuePairs();
		// 使用keyValuePairs...
		List<List<String>> list = new ArrayList<>();
		for (Map.Entry<String, String[]> entry : keyValuePairs.entrySet()) {
			System.out.println(entry.getKey());
			List<String> list1 = Arrays.asList(entry.getValue()).subList(0, Math.min(entry.getValue().length, 200));
			list.add(list1);
		}

		return Result.success(list);
	}
}
